import Vue from 'vue';
import Router from 'vue-router';
const _import = require('./_import_' + process.env.NODE_ENV);
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router);

/* Layout */
import Layout from '@/views/layout/Layout';
import LayoutTree from '@/views/layout/treeLayout';
/* 内容生产布局 */
// import productionLayout from '@/views/production/layout/productionLayout'
/* 选稿库布局 */
// import chooselibraryLayout from '@/views/chooseLibrary/layout/chooseLibraryLayout'
/* 内容编辑布局 */
// import compileLayout from '@/views/compile/layout/compileLayout'
/* 内容审核布局 */
// import reviewLayout from '@/views/review/layout/reviewLayout'
/* 内容发布布局 */
// import releaseLayout from '@/views/release/layout/releaseLayout'
// /* 菜单管理布局 */
// import subMenuLayout from '@/views/systemManage/menuManagement/layout/subMenuLayout'
// /* 组织机构管理布局 */
// import organizationLayout from '@/views/systemManage/organizationManagement/layout/organizationLayout'
/* 栏目管理布局 */
// import programLayout from '@/views/productManage/program/layout/programLayout'
/* 导航管理布局 */
// import appNaviLayout from '@/views/productManage/appNavi/layout/appNaviLayout'
/* 微信公众号管理布局 */
// import wxManageLayout from '@/views/productManage/socialManage/wxManage/layout/wxManageLayout'
/* 微博公众号管理布局 */
// import wbManageLayout from '@/views/productManage/socialManage/wbManage/layout/wbManageLayout'
/* 直播管理布局 */
// import liveBroadcastLayout from '@/views/productManage/liveBroadcast/layout/liveBroadcastLayout'
/* 数字报管理布局 */
// import numPaperLayout from '@/views/productManage/productLibrary/numPaper/layout/numPaperLayout'
/* 稿件管理布局 */
// import copiesManageLayout from '@/views/productManage/productLibrary/copiesManage/layout/copiesManageLayout'
/* 历史库管理布局 */
// import historyLibraryLayout from '@/views/productManage/historyLibrary/layout/historyLibraryLayout'
/* 推荐内容管理布局 */
// import recommendedConbraryLayout from '@/views/productManage/recommendedCon/layout/recommendedConLayout'
/* 专题管理布局 */
// import specialLayout from '@/views/productManage/special/layout/specialLayout'
/* 共享列表管理布局 */
// import cloudSharedListLayout from '@/views/productManage/cloudDraftLibrary/cloudSharedList/layout/cloudSharedListLayout'
/* 我的共享管理布局 */
// import myShareLayout from '@/views/productManage/cloudDraftLibrary/myShare/layout/myShareLayout'
/* 内容管理布局 */
// import QAcontentManageLayout from '@/views/productManage/QAmanage/QAcontentManage/layout/QAcontentManageLayout'
/* 话题管理布局 */
// import QAexamineManageLayout from '@/views/productManage/QAmanage/QAexamineManage/layout/QAexamineManageLayout'
/* 审核管理布局 */
// import QAtopicManageLayout from '@/views/productManage/QAmanage/QAtopicManage/layout/QAtopicManageLayout'
/* 分类管理布局 */
// import QAclassifyManageLayout from '@/views/productManage/QAmanage/QAclassifyManage/layout/QAclassifyManageLayout'
/**
                  * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
                  * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
                  *                                if not set alwaysShow, only more than one route under the children
                  *                                it will becomes nested mode, otherwise not show the root menu
                  * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
                  * name:'router-name'             the name is used by <keep-alive> (must set!!!)
                  * meta : {
                      title: 'title'               the name show in submenu and breadcrumb (recommend set)
                      icon: 'svg-name'             the icon show in the sidebar,
                    }
                  **/
export const constantRouterMap = [
  {
    path: '/login',
    name: 'login',
    component: _import('login/index'),
    hidden: true,
    children: [
      {
        path: 'homePage',
        name: 'homePage',
        component: _import('login/homePage'),
      },
      {
        path: 'companyIntroduction',
        name: 'companyIntroduction',
        component: _import('login/companyIntroduction'),
      },
    ],
  },
  {
    path: '/autologin',
    name: 'autologin',
    component: _import('login/autologin'),
    hidden: true,
  },
  {
    path: '/404',
    component: _import('404'),
    hidden: true,
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    hidden: true,
    children: [
      {
        path: 'dashboard',
        name: 'dashboard',
        component: _import('dashboard/index'),
        meta: { title: '首页', affix: true },
      },
      {
        path: 'busiWorkFlowToDoDetail/:id',
        name: 'busiWorkFlowToDoDetail',
        component: _import(
          'workFlowManage/busiWorkFlowTask/busiWorkFlowTaskDetail'
        ),
        meta: { title: '待办单据详情' },
      },
      {
        path: 'busiWorkFlowHasToDoDetail/:id',
        name: 'busiWorkFlowHasToDoDetail',
        component: _import(
          'workFlowManage/busiWorkFlowTask/busiWorkFlowTaskDetail'
        ),
        meta: { title: '已办单据详情' },
      },
      {
        path: 'workFlowTaskList',
        name: 'workFlowTaskList',
        component: _import(
          'workFlowManage/busiWorkFlowTask/busiWorkFlowTaskList'
        ),
        meta: { title: '更多待办已办' },
      },
    ],
  },
  {
    path: '',
    component: Layout,
    redirect: '/changePassword',
    name: 'ChangePassword',
    hidden: true,
    children: [
      {
        path: 'changePassword',
        component: _import('changePassword/index'),
      },
    ],
  },
  {
    // 用户个人信息修改
    path: '',
    component: Layout,
    redirect: '/changeUserInfo',
    name: 'ChangeUserInfo',
    hidden: true,
    children: [
      {
        path: 'changeUserInfo',
        component: _import('changeUserInfo/index'),
      },
    ],
  },
];

export default new Router({
  mode: 'history',
  scrollBehavior: () => ({
    y: 0,
  }),
  routes: constantRouterMap,
});

export const asyncRouterMap = [
  {
    path: '/login',
    component: _import('login/index'),
    hidden: true,
  },
  {
    path: '/autologin',
    name: 'autologin',
    component: _import('login/autologin'),
    hidden: true,
  },
  {
    path: '/404',
    component: _import('404'),
    hidden: true,
  },
  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/dashboard',
  //   name: 'Dashboard',
  //   hidden: true,
  //   children: [{
  //     path: 'dashboard',
  //     component: _import('dashboard/index')
  //   }]
  // },
  {
    path: '*',
    redirect: '/404',
    hidden: true,
  },
];
